1 <?php
2
3 session_start();
4 require "includes/functions.php";
5 require "includes/db.php";
6
7 if(!isset($_SESSION['user'])) {
8
9 header("location: logout.php");
10
11 }
12
13 $result = "";
14 $info = "";
15 $items = "";
16 $pagenum = "";
17 $per_page = 10;
18
19 $count = $db->query("SELECT * FROM basket");
20
21 $pages = ceil((mysqli_num_rows($count)) / $per_page);
22
23 if(isset($_GET['page'])) {
24
25 $page = $_GET['page'];
26
27 }else{
28
29 $page = 1;
30
31 }
32
33 $start = ($page - 1) * $per_page;
34
35 $orders = $db->query("SELECT * FROM basket LIMIT $start, $per_page");
36
37 if($orders->num_rows) {
38
39 $x = 1;
40
41 $info .= "<table class='table table-hover'>
42 <thead>
43 <th>Order_id</th>
44 <th>Tên trà sữa</th>
45 <th>Đại chỉ</th>
46 <th>Email</th>
47 <th>Di động</th>
48 </thead>
49 <tbody>";
50
51 $items .= "<table class='table table-hover'>
52 <tbody>
53 <tr>
54 <th>Tên</th>
55 <th>Số lượng</th>
56 <td></td>
57 </tr>";
58
59 while($row = $orders->fetch_assoc()) {
60
61 $oid = $row['id'];
62 $id = $row['id']."_ord";
63
64 if($x == 1) {
65
66 $result .= "<input type='hidden' value='".$id."' id='".$id."'><a href='#' style='display: block; background: #efefef; color: #333; border-bottom: 1px solid #ccc; padding: 10px 0px;' onClick=\"func_call('".$id."'); return false\" >ORD_$oid</a>";
67
68 $info .= "<tr>
69 <td>ORD_$oid</td>
70 <td>".$row['customer_name']."</td>
71 <td>".$row['address']."</td>
72 <td>".$row['email']."</td>
73 <td>".$row['contact_number']."</td>
74 </tr>";
75
76 $get_data = $db->query("SELECT * FROM items WHERE order_id='".$oid."'");
77
78 while($data = $get_data->fetch_assoc()) {
79
80 $items .= "<tr>
81 <td>".$data['food']."</td>
82 <td>".$data['qty']."</td>
83 <td></td>
84 </tr>";
85
86 }
87
88 $items .= "<tr>
89 <th>Tổng tiền</th>
90 <th>".$row['total']."</th>
91 <th></th>
92 </tr>
93 ";
94
95 if($row['status'] == "pending") {
96
97 $items .= "<tr>
98 <th>Trạng thái</th>
99 <td>
100 <select onChange=\"change_stat('".$oid."')\" name='status' id='".$oid."' class='form-control'>
101 <option value='pending_$oid' selected>Chờ xử lý</option>
102 <option value='confirmed_$oid'>Đã Hoàn thành</option>
103 </select>
104 </td>
105 <th></th>
106 </tr>";
107
108 }else{
109
110 $items .= "<tr>
111 <th>Trang thái</th>
112 <td>
113 <select onChange=\"change_stat('".$oid."')\" id='".$oid."' name='status' class='form-control'>
114 <option value='pending_$oid' >Chờ xử lý</option>
115 <option value='confirmed_$oid' selected>Đã hoàn thành</option>
116 </select>
117 </td>
118 <th></th>
119 </tr>";
120
121 }
122
123
124 }else{
125
126 $result .= "<input type='hidden' value='".$id."' id='".$id."'><a href='#' style='display: block; background: #efefef; color: #333; border-bottom: 1px solid #ccc; padding: 10px 0px;' onClick=\"func_call('".$id."'); return false\" >ORD_$oid</a>";
127
128 }
129
130
131 $x++;
132 }
133
134 $info .= "</tbody>
135 </table>";
136
137 $items .= "</tbody>
138 </table>";
139
140 }else{
141
142 $result = "No Orders available yet";
143
144 $info = "";
145
146 $items = "";
147
148 }
149
150
151
152 if($_SERVER['REQUEST_METHOD'] == 'GET') {
153
154 if(isset($_GET['delete']) && escape($_GET['delete']) != "") {
155
156 $bird_id = escape($_GET['delete']);
157
158 if($bird_id != "") {
159
160 $query = $db->prepare("DELETE FROM birds WHERE bird_id=? LIMIT 1");
161 $query->bind_param('i', $bird_id);
162
163 if($query->execute()) {
164
165 echo "<script>alert('Record deleted successfully')</script>";
166
167 }else{
168
169 echo "<script>alert('Record was not deleted successfully')</script>";
170
171 }
172
173 }
174
175 }
176
177 }
178
179 ?>
180
181 <!doctype html>
182 <html lang="en">
183 <head>
184 <meta charset="utf-8" />
185 <link rel="icon" type="image/png" href="assets/img/favicon.ico">
186 <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
187
188 <title>Trà Sửa Milk Tea Hương Vị Thơm - Chuẩn Vị Ngon</title>
189
190 <meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0' name='viewport' />
191 <meta name="viewport" content="width=device-width" />
192
193
194 <!-- Bootstrap core CSS -->
195 <link href="assets/css/bootstrap.min.css" rel="stylesheet" />
196
197 <!-- Animation library for notifications -->
198 <link href="assets/css/animate.min.css" rel="stylesheet"/>
199
200 <!-- Light Bootstrap Table core CSS -->
201 <link href="assets/css/light-bootstrap-dashboard.css" rel="stylesheet"/>
202
203
204 <!-- CSS for Demo Purpose, don't include it in your project -->
205 <link href="assets/css/demo.css" rel="stylesheet" />
206
207
208 <!-- Fonts and icons -->
209 <link href="assets/css/pe-icon-7-stroke.css" rel="stylesheet" />
210
211
212 <link href="assets/css/style.css" rel="stylesheet" />
213
214 <script>
215
216 function check() {
217
218 return confirm("Are you sure you want to delete this record");
219
220 }
221
222 function func_call(id) {
223
224 var value = document.getElementById(id).value;
225
226 if(value != "") {
227
228 $.ajax({
229
230 url: 'get_item.php',
231 type: 'post',
232 data: {order_id : value},
233 success: function(data) {
234 //alert(data);
235 $("#details_display").html(data);
236 }
237 });
238
239 }
240
241 }
242
243 function change_stat(id) {
244
245 var option = document.getElementById(id).value;
246
247 $.ajax({
248
249 url: 'get_item.php',
250 type: 'post',
251 data: {status : option},
252 success: function(data) {
253 alert(data);
254 }
255 });
256
257 }
258
259 </script>
260
261 </head>
262 <body>
263
264 <div class="wrapper">
265 <div class="sidebar" data-color="#000" data-image="assets/img/sidebar-5.jpg">
266
267 <!-- you can change the color of the sidebar using: data-color="blue | azure | green | orange | red | purple" -->
268
269
270 <?php require "includes/side_wrapper.php"; ?>
271
272 <div class="main-panel">
273 <nav class="navbar navbar-default navbar-fixed" style="background: #FF5722;">
274 <div class="container-fluid">
275 <div class="navbar-header">
276 <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navigation-example-2">
277 <span class="sr-only">Toggle navigation</span>
278 <span class="icon-bar" style="background: #fff;"></span>
279 <span class="icon-bar" style="background: #fff;"></span>
280 <span class="icon-bar" style="background: #fff;"></span>
281 </button>
282 <a class="navbar-brand" href="#" style="color: #fff;">Đơn hàng</a>
283 </div>
284 <div class="collapse navbar-collapse">
285
286 <ul class="nav navbar-nav navbar-right">
287 <li>
288 <a href="logout.php" style="color: #fff;">
289 Thoát
290 </a>
291 </li>
292 </ul>
293 </div>
294 </div>
295 </nav>
296
297
298 <div class="content">
299 <div class="container-fluid">
300 <div class="row">
301 <div class="col-md-12">
302 <div class="card">
303 <div class="header">
304 <h4 class="title" style="text-align: center">Danh sách Order</h4>
305 </div>
306
307 <div class="row">
308
309 <div class="col-md-12" >
310
311 <br/>
312
313 <div class="col-md-3" style="text-align: center; background: #2abccc; color: #fff; border-right: 1px solid #fff;">
314
315 <h5>Order Id</h5>
316
317 </div>
318
319 <div class="col-md-9" style="background: #2abccc; color: #fff;">
320
321 <h5>Chi tiết đặt bàn</h5>
322
323 </div>
324
325 </div>
326
327 <div class="col-md-3" style="text-align: center;">
328
329 <?php echo $result; ?>
330
331 </div>
332
333 <div id="details_display" class="col-md-8 table-responsive" style="padding: 10px;">
334
335 <?php echo $info; ?>
336
337 <?php echo $items; ?>
338
339 </div>
340
341 </div>
342
343 <div class="content table-responsive table-full-width">
344
345 <p style="padding: 0px 20px;"><?php if($pages >= 1 && $page <= $pages) {
346 for($i = 1; $i <= $pages; $i++) {
347 echo ($i == $page) ? "<a href='orders.php?page=".$i."' style='margin-left:5px; font-weight: bold; text-decoration: none; color: #FF5722;' >$i</a> " : " <a href='orders.php?page=".$i."' class='btn'>$i</a> ";
348 }
349 } ?></p>
350
351 </div>
352 </div>
353 </div>
354
355 </div>
356 </div>
357 </div>
358
359 <footer class="footer">
360 <div class="container-fluid">
361
362 <p class="copyright pull-right">
363 © 2016 <a href="index.php" style="color: #FF5722;">Unique Restaurant</a>
364 </p>
365 </div>
366 </footer>
367
368 </div>
369 </div>
370
371
372 </body>
373
374 <!-- Core JS Files -->
375 <script src="assets/js/jquery-1.10.2.js" type="text/javascript"></script>
376 <script src="assets/js/bootstrap.min.js" type="text/javascript"></script>
377
378 <!-- Checkbox, Radio & Switch Plugins -->
379 <script src="assets/js/bootstrap-checkbox-radio-switch.js"></script>
380
381 <!-- Charts Plugin -->
382 <script src="assets/js/chartist.min.js"></script>
383
384 <!-- Notifications Plugin -->
385 <script src="assets/js/bootstrap-notify.js"></script>
386
387 <!-- Google Maps Plugin -->
388
389 <!-- Light Bootstrap Table Core javascript and methods for Demo purpose -->
390 <script src="assets/js/light-bootstrap-dashboard.js"></script>
391
392 <!-- Light Bootstrap Table DEMO methods, don't include it in your project! -->
393 <script src="assets/js/demo.js"></script>
394
395 <script type="text/javascript">
396 $(document).ready(function(){
397
398 /*notice = $("#notify").val();
399
400 //alert(notice);
401
402 demo.initChartist();
403
404 $.notify({
405 icon: 'pe-7s-gift',
406 message: notice
407
408 },{
409 type: 'danger',
410 timer: 7000
411 });
412
413 });*/
414 </script>
415
416 </html>